package com.ljs.liojbackendjudgeservice.judge;

import com.ljs.libackendmodel.model.codesandbox.QuestionJudgeInfo;
import com.ljs.libackendmodel.model.entity.QuestionSubmit;
import com.ljs.libackendmodel.model.enums.QuestionSubmitLanguageEnum;
import com.ljs.liojbackendjudgeservice.judge.strategy.DefaultJudgeStrategy;
import com.ljs.liojbackendjudgeservice.judge.strategy.JavaLanguageJudgeStrategy;
import com.ljs.liojbackendjudgeservice.judge.strategy.JudgeContext;
import com.ljs.liojbackendjudgeservice.judge.strategy.JudgeStrategy;
import org.springframework.stereotype.Service;

/**
 * 判题管理
 */

@Service
public class JudgeManage {
    QuestionJudgeInfo doJudge(JudgeContext judgeContext){
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy JudgeStrategy = new DefaultJudgeStrategy();
        if (language.equals(QuestionSubmitLanguageEnum.JAVA.getValue())) {
            JudgeStrategy = new JavaLanguageJudgeStrategy();
        }
        return JudgeStrategy.doJudge(judgeContext);
    }
}
